<?php get_header() ?>

<div class="container">
	<div class="row">
    	<div class="col-sm-9 right-col">
        	<h3 class="bar">
        		<?php if(is_category()): ?>
                <a href="javascript:void(0)" rel="nofollow"><?php single_cat_title() ?></a>
        		<?php elseif(is_search()): ?>
                <a href="javascript:void(0)" rel="nofollow">Tìm kiếm với từ khóa '<?php echo get_search_query() ?>'</a>
	            <?php else: ?>

	            <?php endif; ?>
            </h3>
            <div class="row">
            	<?php if ( have_posts() ) : ?>
                <ul class="ul_tieudiem">
                	<?php $cutOff = 250; ?>
                	<?php while ( have_posts() ) : the_post(); ?>
                		<?php $hasThumb = has_post_thumbnail( get_the_ID() ); ?>
                	<!-- items -->
                    <li class="col-md-4 col-sm-6">
                    	<?php if($hasThumb): ?>
                        <a href="<?php the_permalink() ?>" class="thumb">
                            <?php the_post_thumbnail( 'archive-thumb' ); ?>
                        </a>
                    	<?php endif; ?>

                        <h4 class="title">
                            <a href="<?php the_permalink() ?>">
                                <?php the_title() ?>
                            </a>
                        </h4>
                        <p class="lead">
                            <?php #$cutOff = $hasThumb ? 200 : 500; ?> 
                        	<?php echo trim_text(get_the_excerpt(), $cutOff) ?>
                        </p>
                        <p class="chitiet text-right">
                            <a href="<?php the_permalink() ?>"><i class="fa fa-angle-double-right"></i> Chi tiết</a>
                        </p>
                    </li>
					<!--/ items -->
					<?php endwhile; ?>
        		</ul>
	        	<?php else: ?>
				<h4>Hiện chưa có bài viết nào.</h4>
	        	<?php endif; ?>
            </div>
            <?php if(function_exists('wp_paginate')) wp_paginate(); ?>
       </div>
       <?php
       $cateTieuDiem = 4;
       $cateDuAn = 6;
       ?>
    	<div class="col-sm-3 left-col">
        	<div class="left_boxes">
            	<h3 class="bar">
                	<a href="<?php echo get_category_link( $cateTieuDiem ); ?> ">
			            <?php echo get_cat_name( $cateTieuDiem ) ?>
			        </a>
                </h3>
                <?php $queryTieuDiem = new WP_Query( array('cat' => $cateTieuDiem, 'posts_per_page' => 6)); ?>
                <?php if ( $queryTieuDiem->have_posts() ) : ?>
                <ul>
                	<?php while ( $queryTieuDiem->have_posts() ) : $queryTieuDiem->the_post(); ?>
                	<li>
                    	<a href="<?php the_permalink() ?>"><?php echo trim_text(get_the_title(), 40) ?></a>
                    </li>
					<?php endwhile; ?>
                </ul>
            	<?php endif; ?>
            </div>
			<?php wp_reset_postdata(); ?>

            <div class="left_boxes duan_phanphoi">
            	<h3 class="bar">
                	<a href="<?php echo get_category_link( $cateDuAn ); ?> ">
			            <?php echo get_cat_name( $cateDuAn ) ?>
			        </a>
                </h3>
                <?php $queryDuAn = new WP_Query( array('cat' => $cateDuAn, 'posts_per_page' => 6)); ?>
                <?php if ( $queryDuAn->have_posts() ) : ?>
                <ul>
                	<?php while ( $queryDuAn->have_posts() ) : $queryDuAn->the_post(); ?>
                	<li>
                    	<a href="<?php the_permalink() ?>"><?php echo trim_text(get_the_title(), 40) ?></a>
                    </li>
					<?php endwhile; ?>
                </ul>
            	<?php endif; ?>
         	</div>
    		<?php wp_reset_postdata(); ?>
        </div>
        
    </div>            
</div>

<?php get_footer() ?>